#pragma once

#include "DLL.h"
#include <MyViews/Tool.h>
#include "Bezier.h"
#include "BezierManip.h"

namespace My {

class BezierEditor;

class DLL_API ConvertTool : public Tool
{
	enum HitCode {
		htNone,
		htCurve,
		htNode,
		htControlPoint
	};

	struct HitInfo 
	{
		HitCode		code;
		Size		curve;
		Size		node;
		Size		control;
		bool		select;
		float		t;
	};

public:
	ConvertTool(BezierEditor & owner);
public:
	virtual void Activate(); 
	virtual void Deactivate(); 
	virtual void PaintRect(CDC * pDC, const CRect & r);
	virtual void OnLButtonDown(UINT nFlags, CPoint p);
	virtual void OnLButtonDblClk(UINT nFlags, CPoint p);
	virtual void OnLButtonUp(UINT nFlags, CPoint p);
	virtual void OnRButtonDown(UINT nFlags, CPoint p);
	virtual void OnRButtonDblClk(UINT nFlags, CPoint p);
	virtual void OnRButtonUp(UINT nFlags, CPoint p);
	virtual void OnMouseMove(UINT nFlags, CPoint p);
	virtual void OnMouseEnter(UINT nFlags, CPoint p);
	virtual void OnMouseLeave();
	virtual void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	virtual void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	virtual bool OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
private:
	void CuspToSmooth(BezierNode &, Size control) const;
private:
	BezierEditor &	m_Owner;
	HitInfo			m_Hit;
};

} //namespace My
